home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93c.txt
/
000101_icon-group-sender _Sun Nov 21 07:54:22 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-02-02
|
33KB
Received: by cheltenham.cs.arizona.edu; Tue, 23 Nov 1993 18:19:26 MST
Date: 21 Nov 93 07:54:22 GMT
From: noc.near.net!news.delphi.com!usenet@uunet.uu.net (Will Mengarini)
Organization: Delphi Internet
Subject: Re: dos executables from icon
Message-Id: <931121.10462.MENGARINI@delphi.com>
References: <93312.000307U47041@uicvm.uic.edu>, <931114.21573.MENGARINI@delphi.com>, <casCGMCEp.G1I@netcom.com>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
This is the source code of a method for producing executable MS-DOS *.Exe
files from Icon programs using the Icon interpretive system (IconT & IconX).
It should be Makeable with 16-bit or 32-bit compilers on any computer that
can Make the Icon interpretive system itself.
This is a modification of the source code for Version 8.8 of Icon for MS-DOS.
That distribution's *.LZH archives have timestamps 3/22/93 03:17..03:19.
It was developed under Borland C++ v3.1 in Sep 93, & has been in regular
use since then for production of directly-executable MS-DOS Icon programs.
IconT usage remains unchanged except for 2 things.
>> There is now a -E option, which tells IconT to produce a .Exe file
instead of a .Icx file. (Case is significant; the -e option redirects
standard error.) All the other options still work the same way: the -c
option still works to produce linkable ucode, & if both -c & -E are
omitted a .Icx file is produced.
>> When the -E option is used with IconT, the file IconDOS.Exe must be
in the same directory as IconT.Exe.
The .Exe file that IconT outputs can then be executed as a command at the DOS
prompt or from inside a batch job, just like any other .Exe file.
I/O redirection works normally. However, altho IconX.Exe need no longer be
invoked as a command to run the new Icon program--the new Icon program itself
is the command--IconX.Exe must be in one of the directories on the DOS Path.
This is what is needed to install this patch.
>> You must already have set up the directories & files for Making the
Icon interpretive system (IconT & IconX). How to do this is described
in the document IPD205.Doc, timestamp 11/19/92 16:13, which comes with
the Icon v8.8 for MS-DOS distribution. When I refer to files in this
article, I'll use absolute paths that will be correct iff you installed
the Icon hierarchy with \Icon as its root; this is also the assumption
made in IPD205.Doc. In both cases, that's just illustrative; what
really matters is the relative path below \Icon (or wherever).
>> You must have Maked & installed a working IconT & IconX as described in
sections 3 & 4 of IPD205.Doc. Note that the Icon distribution comes
with its own Make.Exe to run its Makefiles, & those Makefiles are not
compatible with the Borland C++ 3.1 Make.Exe. When you run an Icon
Make, you need to cause the directory containing Icon's Make.Exe to
precede the directory containing your C compiler's Make.Exe on the DOS
Path, even tho you'll probably also require that your C compiler's
directory be on Path.
>> You must modify the following 7 files in the Icon hierarchy:
\Icon\Src\h\Config.h
\Icon\Src\IconT\Globals.h
\Icon\Src\IconT\LCode.c
\Icon\Src\IconT\Link.c
\Icon\Src\IconT\TMain.c
\Icon\Src\Runtime\Init.r
\Icon\Src\Runtime\Init.r
The list of modifications takes up most of the rest of this article.
>> You must then reMake both IconT & IconX by following steps 1-3 on page
6 of IPD205.Doc.
>> You must create the following new file in the Icon hierarchy:
\Icon\Src\Runtime\IconDOS.c
Its text is at the end of this article.
>> You must compile that IconDOS.c to produce IconDOS.Exe. How you do that
depends on your particular compiler, but since IconDOS.c is pure
vanilla C, whatever compiler options you used for the other C source
files in the Icon interpreter system should work, except that you
should use the Small memory model instead of Large. (Don't use the Tiny
model, which produces a .Com file--it won't work.) If you have an
optimizing C compiler, I recommend fully optimizing for size. Omit
debugging information; by the time you produce an executable .Exe, that
information would have been clobbered anyway. IconDOS.Exe is not
intended to be a runnable program, but since it looks to MS-DOS like
one, its behavior when you run it can test that you compiled it
correctly. It should produce an error message like this:
error in startup code
C:\ICON\BIN\ICONDOS.EXE: can't read interpreter file header
Anything else (except a different path) means the compilation failed.
IconDOS.Exe must be compiled into the directory that contains
IconT.Exe, or moved into that directory after compilation. Intermediate
files from the compilation, like IconDOS.{Obj,Map}, can be deleted.
After you've done all of this, the -E option to IconT should work.
In the following patch descriptions, a form like this
======Cut Here: \Dir\Name.Ext [replace 6-9]======
line1
line2
line3
--------------------Cut Here---------------------
means that in the file \Dir\Name.Ext, the 4 lines numbered 6-9 are to be
deleted, then replaced by the 3 lines
line1
line2
line3
shown explicitly. Everything shown between the "Cut Here" lines is to be
inserted as is into the file; only the "Cut Here" lines are metadata.
The form
======Cut Here: \Dir\Name.Ext [precede 88]======
line4
line5
--------------------Cut Here---------------------
is similar, but nothing is to be deleted; the lines between the "Cut Here"
lines are just to be inserted before line 88.
============Cut Here: \Icon\Src\h\Config.h [replace 797-833]==========
#ifndef Options
#ifndef Xver
#if ARM || UNIX
#define Options "C:LS:Tce:f:mn:o:p:r:stuv:x"
#else /* ARM || UNIX */
#if MSDOS
#define Options "C:ELS:Tce:f:n:o:p:r:stuv:x"
#else /* MSDOS */
#define Options "C:LS:Tce:f:n:o:p:r:stuv:x"
#endif /* MSDOS */
#endif /* ARM || UNIX */
#else /* Xver */
xver(config.3)
#endif /* Xver */
#endif /* Options */
#ifndef CUsage
#if UNIX
#define CUsage "[-C C-comp] [-T] [-c] [-f{adelns}] [-m] [-n{acest}]\n\
[-o ofile] [-p C-opts] [-r runtime] [-s] [-t] [-u] [-v i]"
#else /* UNIX */
#define CUsage "[-C C-comp] [-T] [-c] [-f{adelns}] [-n{acest}]\n\
[-o ofile] [-p C-opts] [-r runtime] [-s] [-t] [-u] [-v i]"
#endif /* UNIX */
#endif /* CUsage */
#ifndef TUsage
#ifndef Xver
#if ARM || UNIX
#define TUsage "[-cmstu] [-e efile] [-o ofile]"
#else /* ARM || UNIX */
#if MVS || VM
#define TUsage "<-cstu> <-e efile> <-o ofile>"
#else /* MVS || VM */
#if MSDOS
#define TUsage "[-cstuE] [-e efile] [-o ofile]"
#else /* MSDOS */
#define TUsage "[-cstu] [-e efile] [-o ofile]"
#endif /* MSDOS */
#endif /* MVS || VM */
#endif /* ARM || UNIX */
#else /* Xver */
xver(config.4)
#endif /* Xver */
#endif /* TUsage */
-----------------------Cut Here---------------------
=========Cut Here: \Icon\Src\IconT\Globals.h [precede 47]========
#if MSDOS
Global int makeExe Init(0); /* -E: Create .Exe instead of .Icx */
Global long fileOffsetOfStuffThatGoesInICX
Init(0); /* Remains 0 if -E not used */
/* set in link.c, used in lcode.c */
#endif
-----------------------Cut Here---------------------
==========Cut Here: \Icon\Src\Runtime\Init.r [replace 273-331]========
#if MSDOS
int thisIsAnExeFile = 0;
char bytesThatBeginEveryExe[2] = {0,0};
unsigned originalExeBytesMod512, originalExePages;
unsigned long originalExeBytes;
#endif /* MSDOS */
if (!name)
error(name, "no interpreter file supplied");
/*
* Try adding the suffix if the file name doesn't end in it,
* unless this is a MSDOS .Exe file (which already has the ".Exe").
*/
n = strlen(name);
#if MSDOS
if (n >= 4 && !stricmp(".Exe", name + n - 4)) {
thisIsAnExeFile = 1;
fname = pathOpen(name, ReadBinary);
/*
* IconDOS's code for calling IconX from an .Exe passes IconX the
* full path of the .Exe, so using pathOpen() seems redundant &
* potentially inefficient. However, pathOpen() first checks for a
* complete path, & if one is present, doesn't search Path; & since
* MS-DOS has a limited line length, it'd be possible for IconDOS
* to check whether the full path will fit, & if not, use only the
* name. The only price for this additional robustness would be
* the time pathOpen() spends checking for a path, which is trivial.
*/
}
else {
#endif /* MSDOS */
if (n <= 4 || (strcmp(name+n-4,IcodeSuffix) != 0)
&& strcmp(name+n-4,IcodeASuffix) != 0) {
char tname[100];
if ((int)strlen(name) + 5 > 100)
error(name, "icode file name too long");
strcpy(tname,name);
#if MVS
{ /*Begin MVS block*/
char *p;
if (p = index(name, '(')) {
tname[p-name] = '\0';
}
#endif /* MVS */
strcat(tname,IcodeSuffix);
#if MVS
if (p) strcat(tname,p);
} /*End MVS block*/
#endif /* MVS */
#if MSDOS || OS2
fname = pathOpen(tname,ReadBinary); /* try to find path */
#else /* MSDOS || OS2 */
fname = fopen(tname, ReadBinary);
#endif /* MSDOS || OS2 */
} /* end if (n <= 4 || etc for 2 lines */
if (fname == NULL) /* try the name as given */
#if MSDOS || OS2
fname = pathOpen(name, ReadBinary);
#else /* MSDOS || OS2 */
fname = fopen(name, ReadBinary);
#endif /* MSDOS || OS2 */
#if MSDOS
} /* end if (n >= 4 && !stricmp(".Exe", name + n - 4)) */
#endif
if (fname == NULL)
return NULL;
#ifdef Xver
xver(imain.9)
#endif /* Xver */
{
static char errmsg[] = "can't read interpreter file header";
static char exe_errmsg[] = "can't read MS-DOS .Exe header";
#ifdef Header
#if MSDOS
#error
deliberate syntax error
/*
* The MSDOS .Exe-handling code assumes & requires that the executable
* .Exe be followed immediately by the icode itself (actually header.h).
* This is because the following Header fseek() is relative to the
* beginning of the file, which in a .Exe is the beginning of the
* executable code, not the beginning of some Icon thing; & I can't
* check & fix all the Header-handling logic because hdr.h wasn't
* included with my MS-DOS distribution so I don't even know what it does,
* let alone how to keep from breaking it. We're safe as long as
* Header & MSDOS are disjoint.
*/
#endif /* MSDOS */
if (fseek(fname, (long)MaxHeader, 0) == -1)
error(name, errmsg);
#endif /* Header */
#if MSDOS
if (thisIsAnExeFile) {
fread (&bytesThatBeginEveryExe, sizeof bytesThatBeginEveryExe, 1, fname);
if (bytesThatBeginEveryExe[0] != 'M' ||
bytesThatBeginEveryExe[1] != 'Z')
error(name, exe_errmsg);
fread (&originalExeBytesMod512, sizeof originalExeBytesMod512, 1, fname);
fread (&originalExePages, sizeof originalExePages, 1, fname);
originalExeBytes = (originalExePages - 1)*512 + originalExeBytesMod512;
if (fseek(fname, originalExeBytes, 0))
error(name, errmsg);
if (ferror(fname) || feof(fname) || !originalExeBytes)
error(name, exe_errmsg);
}
#endif /* MSDOS */
-----------------------Cut Here---------------------
Next file is changed in 2 places.
Second change is stated in terms of lines in v8.8 file ("old")
and equivalently of lines in that file after first change ("new").
==========Cut Here: \Icon\Src\IconT\LCode.c [precede 47]=========
#if MSDOS
extern long fileOffsetOfStuffThatGoesInICX;
/* defined in Globals.h, set in link.c, used below */
#endif /* MSDOS */
====Cut Here: \Icon\Src\IconT\LCode.c [replace old 1164-6 = new 1169-71]====
#else
#if MSDOS
fseek(outfile, fileOffsetOfStuffThatGoesInICX, 0);
#else
fseek(outfile, 0L, 0);
#endif /* MSDOS */
#endif /* MVS */
-----------------------Cut Here---------------------
Next file is changed in 2 places.
Second change is stated in terms of lines in v8.8 file ("old")
and equivalently of lines in that file after first change ("new").
===========Cut Here: \Icon\Src\IconT\Link.c [precede 75]=========
#ifdef MSDOS
extern char pathToIconDOS[];
#endif /* MSDOS */
========Cut Here: \Icon\Src\IconT\Link.c [precede old 227 = new 231]======
#ifdef MSDOS
/*
* This prepends IconDOS.Exe to outfile, so it'll be executable.
*
* I don't know what that #if Header stuff was about since my MSDOS
* distribution didn't include "hdr.h", but it looks very similar to
* what I'm doing, so I'll put my stuff here, & if somebody who
* understands all the multi-operating-system porting thinks my code could
* be folded into it, having it here should make it easy.
*/
if (makeExe) {
FILE *fIconDOS = fopen (pathToIconDOS, "rb");
char bytesThatBeginEveryExe[2] = {0,0}, oneChar;
unsigned originalExeBytesMod512, originalExePages;
unsigned long originalExeBytes, byteCounter;
if (!fIconDOS)
quit("unable to find IconDOS.Exe in same dir as IconT");
if (setvbuf(fIconDOS, 0, _IOFBF, 4096))
if (setvbuf(fIconDOS, 0, _IOFBF, 128))
quit("setvbuf() failure");
fread (&bytesThatBeginEveryExe, 2, 1, fIconDOS);
if (bytesThatBeginEveryExe[0] != 'M' ||
bytesThatBeginEveryExe[1] != 'Z')
quit("IconDOS header is corrupt");
fread (&originalExeBytesMod512, sizeof originalExeBytesMod512,
1, fIconDOS);
fread (&originalExePages, sizeof originalExePages,
1, fIconDOS);
originalExeBytes = (originalExePages - 1)*512 + originalExeBytesMod512;
if (ferror(fIconDOS) || feof(fIconDOS) || !originalExeBytes)
quit("IconDOS header is corrupt");
fseek (fIconDOS, 0, 0);
for (byteCounter = 0; byteCounter < originalExeBytes; byteCounter++) {
oneChar = fgetc (fIconDOS);
if (ferror(fIconDOS) || feof(fIconDOS) || ferror(outfile))
quit("Error copying IconDOS.Exe");
fputc (oneChar, outfile);
}
fclose (fIconDOS);
fileOffsetOfStuffThatGoesInICX = ftell (outfile);
}
#endif /* MSDOS */
-----------------------Cut Here---------------------
==========Cut Here: \Icon\Src\IconT\TMain.c [replace 70-509]=========
#ifdef MSDOS
char pathToIconDOS[129];
#endif /* MSDOS */
* The following code is operating-system dependent [@tmain.02]. Definition
* of refpath.
*/
#if PORT
/* something is needed */
Deliberate Syntax Error
#endif /* PORT */
#if UNIX || AMIGA || ATARI_ST || MACINTOSH || MSDOS || MVS || OS2 || VM
char *refpath = RefPath;
#endif /* UNIX ... */
#if VMS
char *refpath = "ICON_BIN:";
#endif /* VMS */
* End of operating-system specific code.
*/
char *iconxloc;
* getopt() variables
*/
extern int optindex; /* index into parent argv vector */
extern int optopt; /* character checked for validity */
extern char *optarg; /* argument associated with option */
* main program
*/
novalue main(argc,argv)
int argc;
char **argv;
{
int nolink = 0; /* suppress linking? */
int errors = 0; /* translator and linker errors */
char **tfiles, **tptr; /* list of files to translate */
char **lfiles, **lptr; /* list of files to link */
char **rfiles, **rptr; /* list of files to remove */
char *efile = NULL; /* stderr file */
char buf[MaxFileName]; /* file name construction buffer */
int c, n;
struct fileparts *fp;
#if AMIGA
#if AZTEC_C
struct Process *FindTask();
struct Process *Process = FindTask(0L);
ULONG stacksize = *((ULONG *)Process->pr_ReturnAddr);
if (stacksize < ICONTMINSTACK) {
fprintf(stderr,"Icont needs \"stack %d\" to run\n",ICONTMINSTACK);
exit(-1);
}
#endif /* AZTEC_C */
#endif /* AMIGA */
#if MACINTOSH
#if MPW
InitCursorCtl(NULL);
SortOptions(argv);
#endif /* MPW */
#endif /* MACINTOSH */
iconxloc = (char *)alloc((unsigned)strlen(refpath) + 6);
strcpy(iconxloc, refpath);
strcat(iconxloc, "iconx");
if (strlen(patchpath)>18)
iconxloc = patchpath+18;
/*
* Process options.
*/
while ((c = getopt(argc,argv,Options)) != EOF)
switch (c) {
case 'C': /* Ignore: compiler only */
break;
#ifdef MSDOS
case 'E': /* -E */
makeExe = 1;
break;
#endif
#ifdef Xver
xver(tmain.1)
#endif /* Xver */
case 'L': /* -L: enable linker debugging */
#ifdef DeBugLinker
Dflag = 1;
#endif /* DeBugLinker */
break;
case 'S': /* -S */
fprintf(stderr, "Warning, -S option is obsolete\n");
break;
case 'c': /* -c: compile only (no linking) */
nolink = 1;
break;
case 'e': /* -e file: redirect stderr */
efile = optarg;
break;
case 'f': /* Ignore: compiler only */
break;
case 'm': /* -m: preprocess using m4(1) [UNIX] */
m4pre = 1;
break;
case 'n': /* Ignore: compiler only */
break;
case 'o': /* -o file: name output file */
ofile = optarg;
break;
case 'p': /* -p path: iconx path [ATARI] */
#if ATARI_ST
patharg = optarg;
#endif /* ATARI_ST */
break;
case 'r': /* Ignore: compiler only */
break;
case 's': /* -s: suppress informative messages */
silent = 1;
break;
case 't': /* -t: turn on procedure tracing */
trace = -1;
break;
case 'u': /* -u: warn about undeclared ids */
uwarn = 1;
break;
case 'v': /* Ignore: compiler only */
break;
default:
case 'x': /* -x illegal until after file list */
usage();
}
#ifdef MSDOS
/*
* Define pathToIconDOS as a global accessible from inside
* separately-compiled compilation units.
*/
if( makeExe ){
char *pathCursor;
strcpy (pathToIconDOS, argv[0]);
pathCursor = strrchr (pathToIconDOS, '\\');
if (!pathCursor) {
fprintf (stderr,
"Can't understand what directory IconT was run from.\n");
exit(ErrorExit);
}
strcpy (++pathCursor, "IconDOS.Exe");
}
#endif /* MSDOS */
/*
* Allocate space for lists of file names.
*/
n = argc - optindex + 1;
tptr = tfiles = (char **)alloc((unsigned int)(n * sizeof(char *)));
lptr = lfiles = (char **)alloc((unsigned int)(n * sizeof(char *)));
rptr = rfiles = (char **)alloc((unsigned int)(2 * n * sizeof(char *)));
/*
* Scan file name arguments.
*/
while (optindex < argc) {
if (strcmp(argv[optindex],"-x") == 0) /* stop at -x */
break;
else if (strcmp(argv[optindex],"-") == 0) {
#if ARM
/* Different file naming, so we need a different strategy... */
*tptr++ = "-";
/* Use makename(), pretending we had an input file named "Stdin" */
makename(buf,TargetDir,"Stdin",U1Suffix);
*lptr++ = *rptr++ = salloc(buf); /* link & remove .u1 */
makename(buf,TargetDir,"Stdin",U2Suffix);
*rptr++ = salloc(buf); /* also remove .u2 */
#else /* ARM */
*tptr++ = "-"; /* "-" means standard input */
*lptr++ = *rptr++ = "stdin.u1";
*rptr++ = "stdin.u2";
#endif /* ARM */
}
else {
fp = fparse(argv[optindex]); /* parse file name */
if (*fp->ext == '\0' || smatch(fp->ext, SourceSuffix)) {
makename(buf,SourceDir,argv[optindex], SourceSuffix);
#if VMS
strcat(buf, fp->version);
#endif /* VMS */
*tptr++ = salloc(buf); /* translate the .icn file */
makename(buf,TargetDir,argv[optindex],U1Suffix);
*lptr++ = *rptr++ = salloc(buf); /* link & remove .u1 */
makename(buf,TargetDir,argv[optindex],U2Suffix);
*rptr++ = salloc(buf); /* also remove .u2 */
}
else if (smatch(fp->ext,U1Suffix) || smatch(fp->ext,U2Suffix)
|| smatch(fp->ext,USuffix)) {
makename(buf,TargetDir,argv[optindex],U1Suffix);
*lptr++ = salloc(buf);
}
else
quitf("bad argument %s",argv[optindex]);
}
optindex++;
}
*tptr = *lptr = *rptr = NULL; /* terminate filename lists */
if (lptr == lfiles)
usage(); /* error -- no files named */
/*
* Round hash table sizes to next power of two, and set masks for hashing.
*/
lchsize = round2(lchsize); cmask = lchsize - 1;
fhsize = round2(fhsize); fmask = fhsize - 1;
ghsize = round2(ghsize); gmask = ghsize - 1;
ihsize = round2(ihsize); imask = ihsize - 1;
lhsize = round2(lhsize); lmask = lhsize - 1;
/*
* Translate .icn files to make .u1 and .u2 files.
*/
if (tptr > tfiles) {
if (!silent)
report("Translating");
errors = trans(tfiles);
if (errors > 0) /* exit if errors seen */
exit(ErrorExit);
}
/*
* Link .u1 and .u2 files to make an executable.
*/
if (nolink) { /* exit if no linking wanted */
#if MACINTOSH
#if MPW
/*
* Set type of translator output ucode (.u) files
* to 'TEXT', so they can be easily viewed by editors.
*/
{
char **p;
void setfile();
for (p = rfiles; *p; ++p)
setfile(*p,'TEXT','icon');
}
#endif /* MPW */
#endif /* MACINTOSH */
exit(NormalExit);
}
#if MSDOS
if (ofile == NULL) { /* if no -o file, synthesize a name */
ofile = salloc(makename(buf,TargetDir,lfiles[0],
makeExe ? ".Exe" : IcodeSuffix));
} else { /* add extension if necessary */
fp = fparse(ofile);
if (*fp->ext == '\0' && *IcodeSuffix != '\0') /* if no ext given */
ofile = salloc(makename(buf,NULL,ofile,
makeExe ? ".Exe" : IcodeSuffix));
}
#else /* MSDOS */
if (ofile == NULL) { /* if no -o file, synthesize a name */
ofile = salloc(makename(buf,TargetDir,lfiles[0],IcodeSuffix));
} else { /* add extension if necessary */
fp = fparse(ofile);
if (*fp->ext == '\0' && *IcodeSuffix != '\0') /* if no ext given */
ofile = salloc(makename(buf,NULL,ofile,IcodeSuffix));
}
#endif /* MSDOS */
if (!silent)
report("Linking");
errors = ilink(lfiles,ofile); /* link .u files to make icode file */
/*
* Finish by removing intermediate files.
* Execute the linked program if so requested and if there were no errors.
*/
#if MACINTOSH
#if MPW
/* Set file type to TEXT so it will be executable as a script. */
setfile(ofile,'TEXT','icon');
#endif /* MPW */
#endif /* MACINTOSH */
rmfiles(rfiles); /* remove intermediate files */
if (errors > 0) { /* exit if linker errors seen */
unlink(ofile);
exit(ErrorExit);
}
#if !(MACINTOSH && MPW)
if (optindex < argc) {
if (!silent)
report("Executing");
execute (ofile, efile, argv+optindex+1);
}
#endif /* !(MACINTOSH && MPW) */
exit(NormalExit);
}
* execute - execute iconx to run the icon program
*/
static novalue execute(ofile,efile,args)
char *ofile, *efile, **args;
{
#if !(MACINTOSH && MPW)
int n;
char **argv, **p;
for (n = 0; args[n] != NULL; n++) /* count arguments */
;
p = argv = (char **)alloc((unsigned int)((n + 5) * sizeof(char *)));
*p++ = iconxloc; /* set iconx pathname */
if (efile != NULL) { /* if -e given, copy it */
*p++ = "-e";
*p++ = efile;
}
*p++ = ofile; /* pass icode file name */
#if AMIGA && LATTICE
*p = *args;
while (*p++) {
*p = *args;
args++;
}
#else /* AMIGA && LATTICE */
while (*p++ = *args++) /* copy args into argument vector */
;
#endif /* AMIGA && LATTICE */
*p = NULL;
* The following code is operating-system dependent [@tmain.03]. It calls
* iconx on the way out.
*/
#if PORT
/* something is needed */
Deliberate Syntax Error
#endif /* PORT */
#if AMIGA
#if AZTEC_C
execvp(iconxloc,argv);
return;
#endif /* AZTEC_C */
#if LATTICE
{
struct ProcID procid;
if (forkv(iconxloc,argv,NULL,&procid) == 0) {
wait(&procid);
return;
}
}
#endif /* LATTICE */
#endif /* AMIGA */
#if ARM
{
int i = 7 + strlen(iconxloc);
int j;
char *s;
char buffer[255];
extern int armquote(char *, char **);
sprintf(buffer, "Chain:%s ", iconxloc);
for (p = argv + 1; *p; ++p)
{
j = armquote(*p, &s);
if (j == -1 || i + j >= 255)
{
fprintf(stderr, "Cannot execute: command line too long");
fflush(stderr);
return;
}
strcpy(buffer + i, s);
i += j;
buffer[i] = ' ';
}
buffer[i] = '\0';
system(buffer);
}
#endif /* ARM */
#if ATARI_ST || MACINTOSH
fprintf(stderr,"-x not supported\n");
fflush(stderr);
#endif /* ATARI_ST || ... */
#if MSDOS
/*
* No special handling is needed for an .Exe, since IconX recognizes
* it from the extension & from internal .Exe header data.
*/
#if MICROSOFT || TURBO
execvp(iconxloc,argv); /* execute with path search */
#endif /* MICROSOFT || ... */
#if INTEL_386 || ZTC_386 || HIGHC_386 || WATCOM
fprintf(stderr,"-x not supported\n");
fflush(stderr);
#endif /* INTEL_386 || ... */
#endif /* MSDOS */
#if MVS || VM
#if SASC
exit(sysexec(iconxloc, argv));
#endif /* SASC */
fprintf(stderr,"-x not supported\n");
fflush(stderr);
#endif /* MVS || VM */
#if OS2
execvp(iconxloc,argv); /* execute with path search */
#endif /* OS2 */
#if UNIX
/*
* If an ICONX environment variable is defined, use that.
* If not, first try the predefined path, then search $PATH via execvp.
*/
if ((argv[0] = getenv("ICONX")) != NULL && argv[0][0] != '\0') {
execv(argv[0], argv); /* exec file specified by $ICONX */
quitf("cannot execute $ICONX (%s)", argv[0]);
}
#ifdef HardWiredPaths
#ifdef CRAY
argv[0] = "iconx";
execv(iconxloc, argv);
#else /* CRAY */
argv[0] = iconxloc; /* try predefined file */
execv(argv[0], argv);
#endif /* CRAY */
#endif /* HardWiredPaths */
argv[0] = "iconx";
execvp(argv[0], argv); /* if no iconxloc, search path for "iconx" */
#ifdef HardWiredPaths
quitf("cannot run %s", iconxloc);
#else /* HardWiredPaths */
quitf("cannot find iconx", "");
#endif /* HardWiredPaths */
#endif /* UNIX */
#if VMS
execv(iconxloc,argv);
#endif /* VMS */
* End of operating-system specific code.
*/
-----------------------Cut Here---------------------
==========Cut Here: \Icon\Src\Runtime\IconDOS.c [create]========
* IconDOS.c -- Header for MS-DOS Icon *.Exe (executable) file
*/
#include <stdio.h>
#include <string.h>
#include <alloc.h>
#include <process.h>
int main( int argc, char **argv ){
char *argsToIconX[129], **argsToIconXCursor, **argvCursor;
argsToIconXCursor = argsToIconX; argvCursor = argv;
*argsToIconXCursor++ = "IconX";
while( argc-- ) *argsToIconXCursor++ = *argvCursor++;
*argsToIconXCursor++ = 0;
; execvp( "IconX", argsToIconX );
perror( "Couldn't execvp( \"IconX\", ... )" );
; return 250;
}
-----------------------Cut Here---------------------
My office computer doesn't have a modem, & I usually sleep at the office for
a week at a time, so I'll be slow to respond to e-mail & slower to snailmail.
I try to read comp.lang.icon weekly, but sometimes I miss it. I've had 2
reports of e-mail messages getting lost, & snailmail is also unreliable.
Please don't misconstrue these communications difficulties as signs of
disinterest; I'll try to respond to anyone who needs help getting this patch
installed, or who reports bugs or suggests enhancements.
Will Mengarini; 4739 University Wy NE #1001; Seattle WA 98105-4495
mengarini@delphi.com 206\632-4130